#include<bits/stdc++.h>
#include"utils.cpp" 
using namespace std;





// 根据文件序号定制输入数据生成规则
// fileIndex 文件序号 0~9
int ip(int fileIndex) {

	// Range r = {1, 300, 1000, 1300-1, 0, 30};// n v t
	// MIN r1 = {1, 200, 2, 600, 0, 1};
	// MAX r2 = {300, 500, 300, 1000};
	// MAX r3 = { };

	// 特例的配置 - 换行可以用空格代替
	string as[] = {"1 1X12345", "99"};// "2 123 1000"对应case 0
	// char rg[] = {'X', 'Y', 'E', 'A', 'B', 'C', 'D', 'F'};
	// int len = sizeof(rg)/sizeof(char);
	
	/* 备用变量 */
	long long a, b, c, g, k, l, m, n, w, x, y, z;
	long long t, t1, t2, t3;
	long long ma, mi;
	char c1, c2, c3;
	// string s;
	vector<int> v1;
	/* 备用变量 */
	c1 = ' ';

	map<string, int> m1;
	string s1;
	for(int i=0; i<2000; i++) {
		t1 = R(4, 10);
		s1 = "";
		s1 += ('A'+R(0, 25));
		do {
			for(int j=0; j<t1-1; j++) s1 += 'a' + R(0, 25);
		} while(m1.find(s1)!=m1.end());
		t2 = R(1, 100);
		m1[s1] = t2;
// 		cout << s1 << " : " << m1[s1] << endl;
	}
	list<string> l1;
	for(map<string,int>::iterator it=m1.begin(); it!=m1.end(); it++) {
	    l1.push_back(it->first);
	}

	list<string> l2;
	list<string>::iterator itl, itl2;

	map<string,int>::iterator itm;
	switch (fileIndex){
		/* 标准测试 - 随机的个数n、数值v */
		case 0:
		case 1:
		case 2:
		case 3:
		case 4:
		case 5:
		case 6:
		case 7:
			n = R(1, 10);
			m = R(n, n+30);
			cout << n << " " << m << endl;

			v1 = RL(n, 1, 2000);// 物品标号
			for(int i=0; i<n; i++) {
				itl = l1.begin();
				advance(itl, v1[i]-1);
				l2.push_back(*itl);
				cout << *itl << " " << R(1, 30) << endl;
			}

			for(itl=l2.begin(); itl!=l2.end(); itl++) {
				cout << *itl << " " << R(1, 300) << endl;
				m1.erase(*itl);
			}
			itm=m1.begin();
			for(int i=n; i<m; i++,itm++) {
				cout << itm->first << " " << itm->second << endl;
			}


			// break;
		case 8:
		// case 9:
			n = R(1, 100);
			m = R(1, 100);
			cout << n << " " << m << endl;

			v1 = RL(n, 1, 2000);// 物品标号
			for(int i=0; i<n; i++) {
				itl = l1.begin();
				advance(itl, v1[i]-1);
				cout << *itl << " " << R(1, 30) << endl;
			}

			v1 = RL(m, 1, 2000);// 物品标号
			for(int i=0; i<m; i++) {
				itl = l1.begin();
				advance(itl, v1[i]-1);
				cout << *itl << " " << m1[*itl] << endl;
			}
			break;
		/* 边界测试 - 固定的个数最大值n，随机的大数值v */
		case 9:
			n = 1000;//R(1, 100);
			m = 1000;//R(1, 100);
			cout << n << " " << m << endl;

			v1 = RL(n, 1, 2000);// 物品标号
			for(int i=0; i<n; i++) {
				itl = l1.begin();
				advance(itl, v1[i]-1);
				cout << *itl << " " << R(1, 30) << endl;
			}

			v1 = RL(m, 1, 2000);// 物品标号
			for(int i=0; i<m; i++) {
				itl = l1.begin();
				advance(itl, v1[i]-1);
				cout << *itl << " " << m1[*itl] << endl;
			}
			break;

		/* 特例测试和边界最小值 - 固定的数据个数n的最小值、数值v的最小最大值 和 特例踩坑数据 */
		default:
			cout << as[fileIndex];// 直接写到字符串数组里面，题目要求的换行可以用空格代替
			break;
	}

	
	// cout << a << " " << b << " " << c << " " << d << " ";

	return 0;
}
